// pages/user/afterSaleDetail/afterSaleDetail.js
var app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    state:2,
    states:['已提交','已审核','已接单','已服务','已完成'],
    detailData:{},
    unImg:'../../../images/disc.png' ,
    Img:'../../../images/disc1.png' ,
    work_order_id:"",//服务订单id
    star_h: '../../../images/star-2.png',
    star_y: '../../../images/star-1.png',
    stars: 5,

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    //console.log(options)
    wx.showLoading({
      title: '加载中...',
    })
    this.setData({
      work_order_id: options.detail
    })
    this.getapplyDataDetail();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },
  //查询订单详情
  getapplyDataDetail() {
    var that = this;
    var work_order_id = that.data.work_order_id;
    app.ajax({
      url: 'User/Work/workOrderDetail',
      method: "POST",
      data: {
        work_order_id: work_order_id
      },
      success: function (res) {
        //console.log(res)
        wx.hideLoading();
        if (res.data.code == 1000) {
          that.setData({
            detailData: res.data.data
          })
        }else {
          app.showToast(res.data.message);
        }
      }
    })
  },
  //放大图片
  bigIng: function (e) {
    //var imgs = [];
    //imgs.push(e.currentTarget.dataset.src);
    // wx.previewImage({
    //   urls: imgs,
    // })
    wx.previewImage({
      current: e.currentTarget.dataset.src,
      urls: e.currentTarget.dataset.list,
    })
  },
  // 售后投诉，即工单投诉
  goComplaint: function(){
    var that = this;
    var work_order_id = that.data.work_order_id;
    wx.navigateTo({
      url: '../../complaint/complaint?comType=2&work_order_id=' + work_order_id,
    })

  },
  // 费用详情
  moneyDetail: function(e){
    var that = this;
    var work_order_id = e.currentTarget.dataset.work_order_id;
    wx.navigateTo({
      url: '../moneyDetail/moneyDetail?work_order_id=' + work_order_id,
    })
  },
  //预览图片
  previewImage(e){
    var that=this;
    var imgHead=e.currentTarget.dataset.img;
    wx.previewImage({
      current: imgHead, // 当前显示图片的http链接
      urls: [imgHead] // 需要预览的图片http链接列表
    })
  },
  // 拨打客服电话
  tellPhone(e) {
    var that = this;
    var phone = e.currentTarget.dataset.phone;
    wx.makePhoneCall({
      phoneNumber: phone
    })
  },
})